<?php
	include_once "dataservice.php";
	
	class history_db
	{
		public function Them($TenDangNhap = "", $ThoiGian)
		{
			$sql = "INSERT INTO `tbl_history`(`TenDangNhap`, `ThoiGian`) 
					VALUES ('$TenDangNhap','$ThoiGian')";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function LayDanhSach($TenDangNhap, $ThoiGian)
		{
			$sql = "SELECT * FROM `tbl_history` WHERE 1";
			
			if($TenDangNhap != "")
				$sql .= " AND `TenDangNhap` = '$TenDangNhap'";
			if($ThoiGian != "0000-00-00 00:00:00")
				$sql .= " AND `ThoiGian` = '$ThoiGian'";
			$sql .= " ORDER BY `ThoiGian` DESC";
			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}
	}
?>